<template>
	<el-main class="nopadding">
		<el-container>
			<el-header>
				<div class="left-panel">
				</div>
				<div class="right-panel">
					<div class="right-panel-search">
						<el-input v-model="search.keyword" placeholder="权限名称、别名" clearable></el-input>
						<el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
					</div>
				</div>
			</el-header>
			<el-main class="nopadding">
				<scTable ref="table" :apiObj="apiObj" row-key="levelId" stripe highlightCurrentRow>
					<el-table-column label="#" type="index" width="100"></el-table-column>
					<el-table-column label="行政级别标识" prop="levelId" width="250" :show-overflow-tooltip="true"></el-table-column>
					<el-table-column label="行政级别名称" prop="levelName" width="150"></el-table-column>
					<el-table-column label="数字签名" prop="signature" width="250" :show-overflow-tooltip="true"></el-table-column>
					<el-table-column label="校验签名" prop="md5" width="250" :show-overflow-tooltip="true"></el-table-column>
					<el-table-column label="校验状态" prop="remark" width="100">
						<template #default="scope">
							<el-tag type="success" v-if="(scope.row.signature==scope.row.md5)">校验成功</el-tag>
							<el-tag type="danger" v-else>校验失败</el-tag>
						</template>
					</el-table-column>
					<el-table-column label="操作" fixed="right" align="right" width="100">
						<template #default="scope">
							<el-button-group>
								<el-popconfirm title="确定签名吗？" @confirm="setUserLevelSignature(scope.row, scope.$index)">
									<template #reference>
										<el-button text type="primary" size="small">签名</el-button>
									</template>
								</el-popconfirm>
							</el-button-group>
						</template>
					</el-table-column>
				</scTable>
			</el-main>
		</el-container>
	</el-main>
</template>

<script>
export default {
	name: 'UnitDept Verification List',
	components: {
	},
	data() {
		return {
			showGrouploading: false,
			apiObj: this.$API.system.verification.getUserLevelVerificationList,
			search: {
				keyword: "",
			}
		}
	},
	mounted() {
	},
	methods: {
		async setUserLevelSignature(row) {
			var res = await this.$API.system.verification.setUserLevelSignature.post({levelId:row.levelId});
			if (res.code == 200) {
				this.$refs.table.refresh()
				this.$message.success("签名成功")
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		async upsearch() {
			this.$refs.table.upData(this.search)
		},
	}
}
</script>

<style>
</style>
